﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DMU.Gui
{
    public partial class uc_NhaCungCap : DevExpress.XtraEditors.XtraUserControl
    {
        public  DataTable dtNCC;
        public bool them;//đánh dấu là thêm hay sữu

        help hp = new help();
        Service sv = new Service();

        DevExpress.XtraTab.XtraTabControl tab;
        public uc_NhaCungCap()
        {
            InitializeComponent();
           
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            them = true;
            Gui.GuiPro.frmThemNCC frm = new GuiPro.frmThemNCC(this);
            frm.ShowDialog();
        }

        private void btnNCC_Click(object sender, EventArgs e)
        {
            dtNCC = sv.getDatatable("NhaCungCap_SelectAll", null);
            gridControl1.DataSource = dtNCC;

        }

        private void uc_NhaCungCap_Load(object sender, EventArgs e)
        {
            //dtNCC = sv.getDatatable("K_SelectTop", null);
            //gridControl1.DataSource = dtNCC;
        }

        private void btnSua_Click(object sender, EventArgs e)
        {
            them = false;
            int dem = gridView2.FocusedRowHandle;
            if(dem>=0)
            {
                GuiPro.frmThemNCC frm = new GuiPro.frmThemNCC(this);

                frm.txtMa.Text = gridView2.GetRowCellValue(dem, "MaNCC").ToString();
                frm.txtTen.Text = gridView2.GetRowCellValue(dem, "TenNCC").ToString();
                frm.txtdc.Text = gridView2.GetRowCellValue(dem, "DiaChi").ToString();
                frm.txtSDT.Text = gridView2.GetRowCellValue(dem, "SDT").ToString();
                frm.txtFax.Text = gridView2.GetRowCellValue(dem, "Fax").ToString();
                frm.ShowDialog();

            }

        }

        private void btnXoa_Click(object sender, EventArgs e)
        {

        }
    }
}
